{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# mnist数据探索（1）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "from PIL import Image\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "training_data_file = open(\"mnist_train.csv\", 'r')\n",
    "training_data_list = training_data_file.readlines()\n",
    "training_data_file.close()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+  training_data_list会把所有内容打印出来，量很大\n",
    "+  可以注释掉"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "#print(training_data_list)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "n=0"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 可以反复运行，不停迭代下一张图片"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAADixJREFUeJzt3X+MVfWZx/HPoy1EpRi1EUeRpW1wsxt/TGEkJq0rtbFxlQQag0KMw2Y3O/xREhs3ZolRIak1jT/aqolVqpNCpEAVLYTUpY2z0W6yGgc01ZZtMQ1LZ5nMiBgZYiIRnv4xh82Ac7/nzr3n3nNmnvcrMXPvee655/Eynznn3u+552vuLg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+pMxexhqnr1JetzLCPyDp0jH3Z0s6WEIf43L3g9nPYUkvafRtSpUMnZwkNfs5XHI//8/dh9z9uLufkPRTlfjaZTNLb5O0yd1fzBaX/tqN11dZr1sZ4X9T0jwz+5KZTZO0XNKOEvr4DDM7J/sgRmZ2jqRvqXqzD++QtDK7vVLS9hJ7OUVVZm6uNbO0Sn7tqjbjdSkn+WRDGT+WdKakXnf/ftubGIeZfVmje3tp9BuPPy+zNzPbLGmRRr/1NSRpraRfSvqFpDmSDkha5u5t/+CtRm+LNMGZm1vUW62Zpd9Qia9dkTNeF9IPZ/gBMXGGHxAU4QeCIvxAUIQfCIrwA0ERfiAowg8ERfiBoP4KvmlJ8VROGQsAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "record=training_data_list[n]\n",
    "all_values = record.split(',')\n",
    "inputs = np.asfarray(all_values[1:])\n",
    "labels=int(all_values[0])\n",
    "print(labels)\n",
    "\n",
    "inputs=inputs.reshape([28,28])\n",
    "im = Image.fromarray(np.uint8(inputs))\n",
    "plt.imshow(im)\n",
    "n=n+1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
